package com.tsu.mall.admin.controller;

import com.tsu.mall.common.VO.LayuiTableVO;
import com.tsu.mall.common.VO.ResultVO;
import com.tsu.mall.admin.entity.Menu;
import com.tsu.mall.admin.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

//菜单管理的维护
@Controller
@RequestMapping("/menu")
public class MenuController {
    @Autowired
    private IMenuService imenuService;
    @GetMapping("/menuPage")
    public String menuPage(){
        return "menu";
    }
    @GetMapping("/list")
    @ResponseBody
    public LayuiTableVO list(){
        return  imenuService.doList();
    }

    @PostMapping("/del")
    @ResponseBody
    public ResultVO delete(Integer id) {
        return imenuService.doDelete(id);
    }

    @GetMapping("/{id}")
    @ResponseBody
    public Menu selectById(@PathVariable Integer id){
        return imenuService.getById(id);
    }

    @PostMapping("/save")
    @ResponseBody
    public void save(Menu menu){
        imenuService.saveOrUpdate(menu);
    }
}
